package com.yyds.controller;

import com.yyds.common.MyJSON;
import com.yyds.common.R;
import com.yyds.pojo.PreventPerson;
import com.yyds.service.PreventPersonService;
import com.yyds.service.impl.PersonResidentServiceImpl;
import com.yyds.service.impl.PreventPersonServiceImpl;
import com.yyds.vo.PreventPersonVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/admin/prevent/person")
public class PreventPersonController {
    @Autowired
    private PreventPersonService preventPersonService;

    @RequestMapping("/list")
    public MyJSON<PreventPersonVo> selectAllPreventPersonController(@RequestParam Map<String,Object> params){


        //注意这里使用map来接收参数 前端传的不定参数 都可以封装到map中

        return preventPersonService.selectAllPreventPersonService(params);

    }

    @PostMapping("/deletepreventperson")
    public R deletePreventPersonController (Integer person_id) {
        //根据Id删除出行方式信息
        int result = preventPersonService.deletePreventPersonService(person_id);
        PreventPerson preventPerson = preventPersonService.selectPreventPersonService(person_id);
        if (result==1){
            return R.ok();
        }else{
            return R.error();
        }
    }

    //查全部名字
//    @RequestMapping("/selectAreaName")
//    public R selectAreaNameController() {
//        List<String> list = preventAreaService.selectAreaNameService();
//        return R.ok().data("residentName", list);
//    }
//    //添加封控地区
//    @RequestMapping("/add")
//    public R add(PreventAreaVo preventAreaVo){
//        int result  =preventAreaService.insertPreventAreaService(preventAreaVo);
//        return result > 0 ? R.ok() :R.error();
//    }

}
